import java.util.*;
class Score implements Runnable{
    List<Integer> array = new ArrayList<>();
    int teacher;
    int student;

    public Score(List<Integer> array, int teacher, int student) {
        this.array = array;
        this.teacher = teacher;
        this.student = student;
    }

    @Override
    public synchronized void run() {
        int sum = 0;
        for (int i = 0; i < student; i++) {
            sum += array.get(0);
            array.remove(0);
        }
        System.out.println(sum);
    }
}
public class Main {
    public static void main(String[] args) {
        List<Integer> array = new ArrayList<>();
        Scanner scanner = new Scanner(System.in);
        int teacher = scanner.nextInt();
        int student = scanner.nextInt();
        for (int i = 0; i < student*teacher; i++) {
            array.add(scanner.nextInt());
        }
        Score score = new Score(array,teacher,student);
        Thread[] num;
        num = new Thread[teacher];
        for (int i = 0; i < num.length; i++) {
            num[i] = new Thread(score);
            num[i].start();
        }
    }
}
// public class Main {
//    public static void main(String[] args) throws InterruptedException {
//        Scanner se = new Scanner(System.in);
//        ArrayList<Integer> num=new ArrayList<Integer>();
//        int number_of_teacher =se.nextInt();
//        int number_of_student =se.nextInt();
//        for(int i=0;i<number_of_student*number_of_teacher;i++) {
//            num.add(se.nextInt());
//        }
//        Score score=new Score(num,number_of_teacher, number_of_student);
//        Thread t[]=new Thread[number_of_teacher];
//        for(int i=0;i<t.length;i++) {
//            t[i]=new Thread(score);
//            t[i].start();
//        }
//    }
// }

// class Score implements Runnable{
//    ArrayList<Integer> num=new ArrayList<Integer>();
//    int number_of_teacher,number_of_student;

//    public Score(ArrayList<Integer> num, int number_of_teacher, int number_of_student) {
//        super();
//        this.num = num;
//        this.number_of_teacher = number_of_teacher;
//        this.number_of_student = number_of_student;
//    }


//    public synchronized void run() {
//        int sum = 0;
//        for (int i = 0; i < number_of_student; i++) {
//            sum = sum + num.get(0);
//            num.remove(0);
//        }
//        System.out.println(sum);
//    }
// }